package cn.gov.cus.rmftquartz.service;

import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @author wxming.
 * @date 2018/3/9.
 */
@Service
public class HGLogService {

    /**
     * 格式化展示库里所存的错误信息详情。跟控制台打印出的排版一样。
     * @param eventDate
     * @return
     */
    public String detail(String eventDate){
        String detail = "";//TODO : 查出表里存的错误信息详情。
        detail = detail.replace("\n\n","<br/><br/>");
        detail = detail.replace("\r\n\t","<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        detail = detail.replace("\r\n","<br/>");
        detail = detail.replace("\n","<br/>");

        return detail;
    }

    /**
     * 将Long类型的日期格式化成日期字符串。
     * @param ruleHitBean
     * @return
     */
    private String getHitTime(Map<String,String> ruleHitBean){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String hitTime = "";
        try{
            hitTime = formatter.format(new Date(Long.valueOf(ruleHitBean.get("HITTIME"))));
        }catch (Exception e){
            hitTime = formatter.format(new Date());
        }
        return hitTime;
    }
}
